package com.sirdc.modules.paas.api.mt;

import java.util.HashMap;
import java.util.Map;

import com.sirdc.modules.paas.api.common.CommonRequest;
import com.sirdc.modules.paas.api.common.util.HttpClientUtil;

/**
 * 短信发送请求类.
 * 
 * @author Qing
 * @e-mail lhq@suncco.com
 * @version v1.0
 * @copyright 2010-2015
 * @create-time 2013-9-18 下午5:36:54
 * 
 */
public class MtRequest extends CommonRequest {

	private static final long serialVersionUID = 1811490271131997093L;

	/**
	 * 初始化发送短信请求类.
	 * @param appCode 应用编号.
	 * @param appKey 应用KEY.
	 * @param url 发送短信请求的URL.
	 */
	public MtRequest(String appCode, String appKey, String url) {
		super(appCode, appKey, url);
	}
	
	/**
	 * 发送短信(支持发送定时短信).
	 * @param phoneNumbers 接收短信的目标手机号码集.
	 * @param smsContent 待发送的短信内容.
	 * @param sendTime 发送时间,可实现定时短信功能.固定格式“yyyy-MM-dd HH:mm:ss”,不填或者填错,默认为当前系统时间.
	 * @return
	 */
	public MtResponse send(String phoneNumbers, String smsContent, String sendTime) {		
		Map<String, Object> parameters = new HashMap<String, Object>();
		// 设置应用公共属性.
		parameters.put("appCode", appCode);
		parameters.put("appKey", appKey);
		// 设置业务属性.
		parameters.put("phoneNumbers", phoneNumbers);
		parameters.put("smsContent", smsContent);
		parameters.put("sendTime", sendTime);
		// 发起https请求.
		String responseStr = HttpClientUtil.httpPost(getUrl(), parameters);
		MtResponse response = new MtResponse(responseStr);
		return response;
	}

}
